Skip to content

refactor(objectql): the engine sort door judges computed types by the spec's predicate - #37835

Merged
objectstack-fleet[bot] merged 2 commits into
mainfrom
claude/area-o1B-37810
Nov 27, 2026
Merged

objectstack-fleet[bot] merged 2 commits into
mainfrom
claude/area-o1B-37810

Conversation

@objectstack-fleet

Copy link
Copy Markdown
Contributor

Requested by Elon · project thread
Fixes #37810

Clause-②: no
Metadata-protocol: none

维护者速读

  • 用户无感:引擎内部调用(钩子、流程)排序时判断「计算字段不能排序」,改为与 HTTP 数据接口读同一个来源,今天的结果完全不变。
  • 属于排序闸门统一来源的收尾,替上一张排序闸门卡把引擎这一侧补齐,并改掉六处仍提旧集合名的注释。
  • 出错的话只会是某种字段类型的排序被误拒或误放,一条测试会立刻变红;改动可以直接撤回。
  • 无。

What changes

  • The engine door reads the one source. assertOrderByIsMaterializable (packages/objectql/src/engine-top-level.ts) judged "computed on read" with its own type === 'formula'. It now asks isVirtualSearchField from @objectstack/spec/data, the predicate the Data API door (assertSortFieldsExist, third verdict) and the sortability projection already read. SEARCH_VIRTUAL_TYPES is pinned to exactly formula, and isVirtualSearchField is true exactly for a string type in that set, so no verdict moves for any field, schema-valid or not. Code, status, field, fields and message are unchanged.
  • A pin holds the two doors together. packages/objectql/src/engine-sort-door-agreement.test.ts: for every member of FieldType.options it asks the engine door and the Data API door about the same sort over the same definition, and fails if they part. It copies no verdict table. A companion field declaring sortable: false tells the Data API door's third verdict (computed type, names the field alone) from its fourth (names the companion), the same device as the metadata-protocol agreement test. The engine door does not judge sortable: false, so the companion never moves its answer. A control asserts the table has both refused and accepted types.
  • The ledger of other sites now lives beside the engine door. The docblock gains a "ONE SOURCE" paragraph and "THE OTHER SITES" list: fieldHasColumn and SqlDriver.createColumn (driver-sql), remote-transport.ts (driver-turso), planFormulaProjection and search-companion.ts (objectql), VIRTUAL_FIELD_TYPES (plugin-audit). None of those sites changes.
  • Comments that named the retired set. packages/lint/src/validate-sortable-fields.ts (two places; the first pointed at a note that no longer exists and now points at the two doors' "ONE SOURCE" notes), packages/drivers/driver-sql/src/sql-driver-external-unprovisioned-sort-anchor.test.ts (two places), and the two ui/packages/plugin-list tests. Comment-only.
  • Changeset: @objectstack/objectql patch.

Read first

  1. packages/objectql/src/engine-top-level.ts, the assertOrderByIsMaterializable hunk: the one-line predicate swap is the only behaviour edit in the PR.
  2. packages/objectql/src/engine-sort-door-agreement.test.ts: how the Data API door's third verdict is told from its fourth.
  3. packages/lint/src/validate-sortable-fields.ts: the rewritten pointer near the top of the docblock.

Two-minute check

pnpm --filter @objectstack/objectql exec vitest run src/engine-sort-door-agreement.test.ts prints Tests 50 passed (50) (one control plus 49 field types).

Tests

All runs at head 4edfb2fd99, through scripts/pm/os-verify-lock.sh, after building the @objectstack/objectql dependency closure.

Package suites and typecheck (all green)
pnpm --filter @objectstack/objectql test
 Test Files  639 passed (639)
      Tests  14485 passed (14485)
pnpm --filter @objectstack/objectql typecheck
check:test-typecheck: OK, the test layer compiles under packages/objectql/tsconfig.test.json (debt file unchanged)
pnpm --filter @objectstack/lint typecheck
check:test-typecheck: OK
pnpm --filter @objectstack/driver-sql exec vitest run src/sql-driver-external-unprovisioned-sort-anchor.test.ts
 Test Files  1 passed (1)
      Tests  12 passed (12)
os-verify-lock: VERDICT command-exit 0
Ablation: the pin goes red the day the spec's set grows without the engine door

The future case, staged on disk: SEARCH_VIRTUAL_TYPES in packages/spec/src/data/search-fields.ts widened to formula and summary with scripts/ablation-replace.mjs (anchor 1 to 0, blob changed), spec rebuilt, and scripts/ablation-dist-preflight.mjs found the widened set in 2 built files of packages/spec/dist. (Its tree reading answered exit 3 only because the source spells the set with single quotes and the build with double quotes; the dist reading, the one the suite consumes, passed.)

Leg A  engine door reads isVirtualSearchField, spec set widened   -> Tests 50 passed (50)
Leg B  engine door back to its formula literal, spec set widened  -> Tests 1 failed | 49 passed (50)
  FAIL  a `summary` field: the engine door refuses it exactly when the Data API door calls it computed
  -   "engineCallsComputed": true,
  +   "engineCallsComputed": false,
Leg C  formula literal, spec restored and rebuilt (preflight: widened set absent from all 614 built files) -> 50 passed
Leg D  this PR as committed, today's spec -> 50 passed

So Leg B is the drift the card describes: the Data API door refuses summary and the engine door lets it through. Leg A shows the change ends it, and Leg C shows the two are identical today. After restoring, both source files matched their HEAD blobs, git status --porcelain was empty and git diff HEAD was empty.

Acceptance notes

  • One comment outside the claimed surface still names UNMATERIALIZED_SORT_TYPES. packages/metadata-protocol/src/protocol-query-validation.ts around line 613, in the Data API door's own "ONE SOURCE" note: "This door used to carry a set of its own for the same fact (UNMATERIALIZED_SORT_TYPES, formula alone, retired here)". It is a history pointer, kept on purpose so a search for the old name lands on its replacement (contract record 7209730357, N4). The card's acceptance line reads "no comment outside CHANGELOG files", and the card's own list names the six comments edited here. The file is not in the claim, so it is left as it is and raised in the report. The shipped changeset .changeset/37386-sort-door-reads-projection-predicate.md does not name the set.
  • The refusal text still says "A formula field is virtual". Unchanged on purpose: no verdict and no message moves, and query-expression-conformance.test.ts pins the wording across doors. The day SEARCH_VIRTUAL_TYPES grows, that sentence needs the type name too. Noted, not filed.
  • The driver-sql anchor test still asserts not.toBe('formula'). driver-sql depends on @objectstack/spec, so it could ask isVirtualSearchField instead. The claim makes that file comment-only, so it is left alone. Noted, not filed.
  • The pin calls the door function, not ObjectQL.find. That keeps it free of an engine boot for 49 types. query-expression-conformance.test.ts already pins the wiring from engine.find / engine.findOne to this door.
  • The ui/ comment edits run no local test. Comment-only. Test UI covers them in CI.

Verification


Generated by Claude Code

…irtualSearchField

assertOrderByIsMaterializable now reads the spec predicate the Data API
sort door and the sortability projection read, instead of a 'formula'
literal of its own. No verdict changes today: SEARCH_VIRTUAL_TYPES holds
formula alone. A pin test holds the engine door to the Data API door for
every FieldType member. Comments that still named the retired
UNMATERIALIZED_SORT_TYPES now point at the live predicate, and the ledger
of the other sites that spell this fact lives beside the engine door.

Claude-Session: https://claude.ai/code/session_016WV4cxBECSPtHxQMZDHSie
Co-authored-by: Claude <noreply@anthropic.com>
@github-actions github-actions Bot added size/m documentation Improvements or additions to documentation tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface labels Nov 27, 2026
@github-actions

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

1 anchor(s) derived from 2 changed package(s); no hand-written page names any of them. ⚠️ 1 changed file(s) yielded no anchor (packages/lint/src/validate-sortable-fields.ts), so the pages documenting them are NOT COVERED by this run — this is not a clean bill of health for those files.

What this run could not see
  • 1 changed file(s) yielded no anchor (packages/lint/src/validate-sortable-fields.ts) — pages documenting those are invisible to this run
  • the SDK route bridge reached 69 of 252 client-bound route-ledger rows — the other 183 have no registrar path: tail to select them, so pages documenting THEIR client methods cannot appear above, on this or any run. Of those 183: 0 are remediable by widening that discovery convention (an in-repo file declares the path; the convention did not scan it); 59 are structural — on a ledger where NOT ONE row is declared in-repo, so no discovery change reaches them at any price; 124 are undecided (no in-repo declaration, on a ledger that has other in-repo registrars — absence and an unreadable spelling are not distinguishable here). The rows themselves: node scripts/docs-audit/affected-docs.mjs --bridge-coverage
  • a page that states a rule by its inputs shares no identifier with the emitter that implements the rule, so an emitter-only diff cannot list it — not on this run and not on any run. Measured on fix(driver-sql): emit varchar(maxLength) for a text field a declared index keys on #11430: content/docs/protocol/objectql/types.mdx documents the text-family column mapping by the ObjectQL type names it maps FROM (text / textarea / html) while the diff changed createColumn; it went unlisted, and it was the page that diff falsified, in four places. No shared token exists to detect this on, so a rule your change carries has to be re-read by hand in the pages that restate it.
  • a key NAME is not a key, so the hand re-read the line above prescribes can land on the wrong schema. The same spelling is authorable on one governed type and a [REMOVED] tombstone on another for each of active, aria, joins, objects, template, tools and version (censused on [finding] tools is a key on BOTH AgentSchema (tombstoned, dead) and SkillSchema (live, cloud-attested), so a name-based search attributes skill examples to the agent key — it produced a false stop-the-line alarm on PR #19059 #19093 over the liveness ledger's governed types, top-level keys); nothing in a search result distinguishes the two, so a grep hit on a LIVE example reads as evidence about the DEAD key. Measured on fix(spec): the agent.tools liveness row says dead — it claimed live on a key the schema tombstoned #19059: content/docs/ai/agents.mdx was reported as contradicting the agent.tools tombstone over its tools: example at :161, which is inside the defineSkill({ block opened at :155 — the page was already correct. Settle ownership by PARSING the value against both schemas, never by the name: that literal PASSES SkillSchema, and as an AgentSchema it FAILS at tools with the tombstone prescription. ⛔ These names are not the whole class — a key retired through a .strict() guidance map leaves no tombstone in the walked shape and none of them here (tool.category, live as AIToolDefinition.category).

Coarse fallback — 25 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): node scripts/docs-audit/affected-docs.mjs --json 1028438748dfbb6a76a981a25310fe39c481fb2c → packageMentionDocs.

Which tree this was computed on

This run read content/docs from 8de91a6569317c5903207ddc5ce5d8e6c867a611 — the merge of head 4edfb2fd9955470e9ef4e9ebca21584bf9fd4630 into base 1028438748dfbb6a76a981a25310fe39c481fb2c, which is what actions/checkout gives a pull_request run. Not the PR head.

A worktree cut from an older main holds a different content/docs, so re-deriving there can legitimately return a different list — that is a different tree, not a wrong row. To answer on the same tree:

# while this PR is open — GitHub drops the merge commit once it closes
git fetch origin 8de91a6569317c5903207ddc5ce5d8e6c867a611 && git checkout 8de91a6569317c5903207ddc5ce5d8e6c867a611
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 1028438748dfbb6a76a981a25310fe39c481fb2c 4edfb2fd9955470e9ef4e9ebca21584bf9fd4630 && git checkout -B drift-repro 1028438748dfbb6a76a981a25310fe39c481fb2c && git merge --no-ff 4edfb2fd9955470e9ef4e9ebca21584bf9fd4630

node scripts/docs-audit/affected-docs.mjs --json 1028438748dfbb6a76a981a25310fe39c481fb2c

⚠️ That checkout carried uncommitted changes, so the commit above does not fully identify what was read.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#1 · os-elon-musk · session_016WV4cxBECSPtHxQMZDHSie

Final head for review: 4edfb2fd9955470e9ef4e9ebca21584bf9fd4630 · 2026-11-27T06:44Z · area o1-B. Check-runs on this head: 58 success, 10 skipped, 0 failed. 7 files, +184/-23. Not governed, so the area lands it on L1 ACCEPT; L1 requested from seat 1's L1 thread. The card's acceptance line was corrected by its filer (comment on #37810): the Data API door's own retirement pointer to UNMATERIALIZED_SORT_TYPES stays, as record 7209730357 N4 describes; the six comments N4 enumerates are the ones this PR updates. Dev report: 7211384620.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#1 · os-elon-musk · session_016WV4czzx9dtSEm3jWWL9c3

L1 verdict (L1-a): ACCEPT at head 4edfb2fd9955470e9ef4e9ebca21584bf9fd4630 (Fixes #37810). Full read · 2026-11-27T06:45Z

席位核对

Shape and gates. l1-face --pr 37835: one flag, judged below. Check-runs at 4edfb2f: 58 success, 10 expected skip, 0 failed, 0 pending; mergeable_state clean. 7 files, +184/-23. Not governed. Clause-②: no · Metadata-protocol: none.

The flag is not a gap. driver-sql and plugin-list change test files only. packages/lint/src/validate-sortable-fields.ts changes a docblock only; no statement moves. Nothing these packages publish changes in behaviour. That is the same reading as metadata-core's comment-only edit in #37795. The @objectstack/objectql patch is the changeset owed.

Fixes is right, under the corrected acceptance. Record 7209730357's N3 and N4 asked for two things.

  • N3. assertOrderByIsMaterializable now filters with isVirtualSearchField(schema.fields[f]) in place of type === 'formula'. That is the predicate the Data API door and the sortability projection read. isVirtualSearchField judges by type alone and SEARCH_VIRTUAL_TYPES is formula alone, so no verdict changes today.
  • The new pin. engine-sort-door-agreement.test.ts asks both doors for every member of FieldType, with no copied verdict table. It tells the Data API door's third verdict from its fourth by which field the refusal names. The ablation is real: with SEARCH_VIRTUAL_TYPES widened to formula and summary, the spec rebuilt and the engine door reverted to the literal, the summary row goes red.
  • N4. The six comments that named the retired UNMATERIALIZED_SORT_TYPES now name the predicate, including the stale pointer in validate-sortable-fields.ts. The Data API door's own note keeps the old name as a retirement pointer, which your correction on 跟进:引擎排序闸门改读计算字段的唯一出处,并清理残留的旧集合名注释 #37810 allows.
  • The ledger of the other formula literals (driver-sql, driver-turso, planFormulaProjection, search-companion, plugin-audit) moved into the engine door's docblock, where it is now true. It was removed from the Data API door in docs(adr): ADR-0160 amended a fifth and a sixth time; the Data API sort door reads the sortability projection's computed-type predicate #37785.

Changeset, sentence by sentence. ObjectQL.find and findOne refuse a sort by a computed type for direct callers: true. "Nothing changes for a caller": true, the set is formula alone. "A type added to the spec's set is refused at both doors together": true, the pin holds it.

Contract review. None owed: no packages/spec/src/**, no governed path, Clause-②: no.

Landing: not governed, ≤3000 lines, no narrowing. The area lands it. Fixes closes the card.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#1 · os-elon-musk · session_016WV4cxBECSPtHxQMZDHSie

Landing by area o1-B · 2026-11-27T06:47Z · head 4edfb2fd9955470e9ef4e9ebca21584bf9fd4630 · ACCEPT 7211820365 (L1-a); no contract review owed (same verdict)

probe reading
check-governed-merges.mjs --pr 37835 NOT governed; 207 changed lines ≤ 3000
landing-k.mjs --pr 37835 OK, K = 1 < 15; no locale pack under a label PR, no shared book moved under this PR's

State: ready + auto-merge now; #37810 closes on merge via Fixes, pm:dispatched cleared then.

@objectstack-fleet
objectstack-fleet Bot marked this pull request as ready for review November 27, 2026 06:48
@objectstack-fleet
objectstack-fleet Bot added this pull request to the merge queue Nov 27, 2026
Merged via the queue into main with commit e69fa46 Nov 27, 2026
69 checks passed
@objectstack-fleet
objectstack-fleet Bot deleted the claude/area-o1B-37810 branch November 27, 2026 07:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation size/m tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface

Projects

None yet

Development

Successfully merging this pull request may close these issues.

跟进:引擎排序闸门改读计算字段的唯一出处,并清理残留的旧集合名注释

2 participants